package com.jxdinfo.hussar.example.cggl.materialpurchaseflow.service.impl;

import com.jxdinfo.hussar.support.datasource.annotations.HussarDs;
import com.jxdinfo.hussar.platform.core.utils.HussarUtils;
import com.jxdinfo.hussar.support.exception.HussarException;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.service.MaterialPurchaseFlowService;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.model.MaterialPurchaseFlow;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.dao.MaterialPurchaseFlowMapper;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.model.MaterialPurchaseItem;
import com.jxdinfo.hussar.workflow.manage.engine.TaskEngineService;
import com.jxdinfo.hussar.common.tfmodel.TfModelEnum;
import com.jxdinfo.hussar.common.security.BaseSecurityUtil;
import com.jxdinfo.hussar.support.transaction.core.annotation.HussarTransactional;
import com.jxdinfo.hussar.workflow.engine.response.BpmResponseResult;
import com.jxdinfo.hussar.support.mp.base.query.generator.SingleTableQueryGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashMap;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jxdinfo.hussar.support.mp.base.query.generator.superquery.SuperQueryGenerator;
import org.springframework.aop.framework.AopContext;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.service.MaterialPurchaseItemService;
import java.util.ArrayList;
import com.jxdinfo.hussar.workflow.engine.constant.BpmConstant;
import java.util.Map;
import com.jxdinfo.hussar.workflow.manage.engine.InstanceEngineService;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.dto.MaterialPurchaseFlowDto;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.service.MaterialPurchaseFlowMasterService;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.model.MaterialPurchaseFlowMaster;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.model.MaterialPurchaseFlow;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.dao.MaterialPurchaseFlowMapper;
import com.jxdinfo.hussar.platform.core.base.apiresult.ApiResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import com.jxdinfo.hussar.platform.core.utils.StringUtil;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.dto.MaterialPurchaseFlowMaterialpurchaseflowdataset1;
import com.jxdinfo.hussar.example.cggl.materialpurchaseflow.vo.MaterialPurchaseFlowPageVO;
import java.util.Collections;

/**
 * 采购信息流程主子表服务实现类
 */
@Service("cggl.materialpurchaseflow.MaterialPurchaseFlowServiceImpl")
@HussarDs("master")
public class MaterialPurchaseFlowServiceImpl implements MaterialPurchaseFlowService {

    private static final Logger logger = LoggerFactory.getLogger(MaterialPurchaseFlowServiceImpl.class);

    private static final String RETURN_CODE = "0";

    @Autowired
    private MaterialPurchaseFlowMasterService materialPurchaseFlowMasterService;

    @Autowired
    private MaterialPurchaseFlowMapper materialPurchaseFlowMapper;

    @Autowired
    private MaterialPurchaseItemService materialPurchaseItemService;

    @Override
    public ApiResponse<MaterialPurchaseFlow> formQuery(String id) {
        try {
            return ApiResponse.success(materialPurchaseFlowMapper.formQuery(id));
        } catch (Exception e) {
            throw new HussarException(TfModelEnum.TF_FORM_QUERY_FAILED.getMessage());
        }
    }

    @Override
    @HussarTransactional
    public ApiResponse<String> insertOrUpdate(MaterialPurchaseFlow materialPurchaseFlow) {
        try {
            MaterialPurchaseFlowMaster materialPurchaseFlowMaster = materialPurchaseFlow.gainMaterialPurchaseFlowMaster();
            materialPurchaseFlowMasterService.saveOrUpdate(materialPurchaseFlowMaster);
            LambdaQueryWrapper<MaterialPurchaseItem> ew0 = new LambdaQueryWrapper<>();
            ew0.eq(MaterialPurchaseItem::getMaterialPurchaseId, materialPurchaseFlowMaster.getId());
            materialPurchaseItemService.remove(ew0);
            List<MaterialPurchaseItem> materialPurchaseItems = materialPurchaseFlow.gainMaterialPurchaseItemArray();
            if (null != materialPurchaseItems) {
                for (MaterialPurchaseItem materialPurchaseItem : materialPurchaseItems) {
                    materialPurchaseItem.setMaterialPurchaseId(materialPurchaseFlowMaster.getId());
                }
                materialPurchaseItemService.saveOrUpdateBatch(materialPurchaseItems);
            }
            return ApiResponse.success(String.valueOf(materialPurchaseFlowMaster.getId()), "");
        } catch (Exception e) {
            throw new HussarException(e.getMessage());
        }
    }

    @Override
    @HussarTransactional
    public ApiResponse<String> flowFormSubmitReject(MaterialPurchaseFlowDto materialPurchaseFlowDto) {
        MaterialPurchaseFlow materialPurchaseFlow = materialPurchaseFlowDto.getFormdata();
        try {
            MaterialPurchaseFlowMaster materialPurchaseFlowMaster = materialPurchaseFlow.gainMaterialPurchaseFlowMaster();
            materialPurchaseFlowMasterService.saveOrUpdate(materialPurchaseFlowMaster);
            LambdaQueryWrapper<MaterialPurchaseItem> ew0 = new LambdaQueryWrapper<>();
            ew0.eq(MaterialPurchaseItem::getMaterialPurchaseId, materialPurchaseFlowMaster.getId());
            materialPurchaseItemService.remove(ew0);
            List<MaterialPurchaseItem> materialPurchaseItems = materialPurchaseFlow.gainMaterialPurchaseItemArray();
            if (null != materialPurchaseItems) {
                for (MaterialPurchaseItem materialPurchaseItem : materialPurchaseItems) {
                    materialPurchaseItem.setMaterialPurchaseId(materialPurchaseFlowMaster.getId());
                }
                materialPurchaseItemService.saveOrUpdateBatch(materialPurchaseItems);
            }
            String returnCode = ((MaterialPurchaseFlowService) AopContext.currentProxy()).formsubmitreject(materialPurchaseFlowDto, String.valueOf(materialPurchaseFlowMaster.getId()));
            if (BpmConstant.SUCCESS_CODE.equals(returnCode)) {
                return ApiResponse.success(TfModelEnum.TF_PROCESS_FORM_WAS_SUCCESSFULLY_SUBMITTED.getMessage());
            } else {
                throw new HussarException(TfModelEnum.TF_FAILED_TO_SUBMIT_THE_PROCESS_FORM.getMessage());
            }
        } catch (Exception e) {
            throw new HussarException(e.getMessage());
        }
    }

    @Override
    @HussarTransactional
    @HussarDs("master")
    public String formsubmitreject(MaterialPurchaseFlowDto materialPurchaseFlowDto, String businessKey) {
        Map<String, String> appointMap = new HashMap<>();
        Map<String, Object> variable = new HashMap<>();
        try {
            if (HussarUtils.isEmpty(BaseSecurityUtil.getUser())) {
                throw new HussarException(TfModelEnum.TF_FAILED_T0_OBTAIN_USER_INFORMATION.getMessage());
            }
            String taskId = materialPurchaseFlowDto.getTaskId();
            String comment = materialPurchaseFlowDto.getComment();
            if (materialPurchaseFlowDto.getFlowSelect() == null) {
                appointMap.put(BpmConstant.STATIC_APPOINT_ASSIGNEE, materialPurchaseFlowDto.getParticipantSelect());
            } else {
                appointMap.put(materialPurchaseFlowDto.getFlowSelect(), materialPurchaseFlowDto.getParticipantSelect());
                variable.put(BpmConstant.BPM_NEXT_NODE, materialPurchaseFlowDto.getFlowSelect());
            }
            if (materialPurchaseFlowDto.getSelectBranches() != null) {
                List<String> nextNodeIds = new ArrayList<>();
                for (Map<String, String> map : materialPurchaseFlowDto.getSelectBranches()) {
                    appointMap.put(map.get("flowSelect"), map.get("participants"));
                    nextNodeIds.add(map.get("flowSelect"));
                }
                variable.put(BpmConstant.BPM_NEXT_NODE, String.join(",", nextNodeIds));
            }
            // 判断是否设置会签
            if (materialPurchaseFlowDto.getMultiType() != null) {
                variable.put(BpmConstant.MULTI_TYPE, materialPurchaseFlowDto.getMultiType());
                variable.put(BpmConstant.MULTI_FINISH_CONDITION, materialPurchaseFlowDto.getMultiFinishCondition());
            }
            String processDefinitionKey = materialPurchaseFlowDto.getProcessDefinitionKey();
            String userId = String.valueOf(BaseSecurityUtil.getUser().getId());
            if (HussarUtils.isEmpty(taskId)) {
                BpmResponseResult startResult;
                startResult = InstanceEngineService.startProcessInstanceByKey(processDefinitionKey, userId, businessKey, null);
                if (BpmConstant.SUCCESS_CODE.equals(startResult.getCode())) {
                    taskId = (String) startResult.getResult().getJSONObject(0).get("taskId");
                } else {
                    throw new HussarException(TfModelEnum.TF_FAILED_TO_CREATE_A_START_NODE.getMessage());
                }
            }
            BpmResponseResult bpmResponseResult = TaskEngineService.completeLeapTask(taskId, userId, appointMap, null, comment, variable);
            return bpmResponseResult.getCode();
        } catch (Exception e) {
            throw new HussarException(e.getMessage());
        }
    }

    @Override
    @HussarTransactional
    public ApiResponse<String> initialNodeReject(MaterialPurchaseFlowDto materialPurchaseFlowDto) {
        // 引用数据模型
        String taskId = materialPurchaseFlowDto.getTaskId();
        String comment = materialPurchaseFlowDto.getComment();
        try {
            MaterialPurchaseFlow materialPurchaseFlow = materialPurchaseFlowDto.getFormdata();
            MaterialPurchaseFlowMaster materialPurchaseFlowMaster = materialPurchaseFlow.gainMaterialPurchaseFlowMaster();
            materialPurchaseFlowMasterService.saveOrUpdate(materialPurchaseFlowMaster);
            LambdaQueryWrapper<MaterialPurchaseItem> ew0 = new LambdaQueryWrapper<>();
            ew0.eq(MaterialPurchaseItem::getMaterialPurchaseId, materialPurchaseFlowMaster.getId());
            materialPurchaseItemService.remove(ew0);
            List<MaterialPurchaseItem> materialPurchaseItems = materialPurchaseFlow.gainMaterialPurchaseItemArray();
            if (null != materialPurchaseItems) {
                for (MaterialPurchaseItem materialPurchaseItem : materialPurchaseItems) {
                    materialPurchaseItem.setMaterialPurchaseId(materialPurchaseFlowMaster.getId());
                }
                materialPurchaseItemService.saveOrUpdateBatch(materialPurchaseItems);
            }
        } catch (Exception e) {
            throw new HussarException(e.getMessage());
        }
        return ((MaterialPurchaseFlowService) AopContext.currentProxy()).initialnodereject(taskId, comment);
    }

    @Override
    @HussarTransactional
    @HussarDs("master")
    public ApiResponse<String> initialnodereject(String taskId, String comment) {
        BpmResponseResult bpmResponseResult;
        try {
            if (HussarUtils.isEmpty(BaseSecurityUtil.getUser())) {
                throw new HussarException(TfModelEnum.TF_FAILED_T0_OBTAIN_USER_INFORMATION.getMessage());
            }
            bpmResponseResult = TaskEngineService.rejectToFirstTask(taskId, String.valueOf(BaseSecurityUtil.getUser().getId()), comment, null, true, null);
            if (BpmConstant.SUCCESS_CODE.equals(bpmResponseResult.getCode())) {
                return ApiResponse.success("");
            }
            throw new HussarException(bpmResponseResult.getMsg());
        } catch (Exception e) {
            throw new HussarException(e.getMessage());
        }
    }

    @Override
    public ApiResponse<MaterialPurchaseFlowPageVO> hussarQueryPage(Page<MaterialPurchaseFlow> page) {
        try {
            Page<MaterialPurchaseFlow> pager = new Page<>(page.getCurrent(), page.getSize());
            Map<String, String[]> parameterMap = new HashMap<>();
            String[] orderParameter = new String[1];
            if (page.orders() != null) {
                for (OrderItem orderItem : page.orders()) {
                    if (orderItem.isAsc()) {
                        orderParameter[0] = orderItem.getColumn() + ",asc;";
                    } else {
                        orderParameter[0] = orderItem.getColumn() + ",desc;";
                    }
                }
            }
            parameterMap.put("orderRule", orderParameter);
            MaterialPurchaseFlowPageVO materialPurchaseFlowPageVO = new MaterialPurchaseFlowPageVO();
            // 查询条件构造器,将排序条件封装成QueryWrapper
            SingleTableQueryGenerator singleTableQueryGenerator = new SingleTableQueryGenerator();
            QueryWrapper<MaterialPurchaseFlow> queryWrapper = singleTableQueryGenerator.initQueryWrapper(new MaterialPurchaseFlow(), parameterMap);
            List<MaterialPurchaseFlow> list = materialPurchaseFlowMapper.hussarQueryPage(pager, queryWrapper);
            materialPurchaseFlowPageVO.setData(list);
            materialPurchaseFlowPageVO.setCount(pager.getTotal());
            materialPurchaseFlowPageVO.setCode(RETURN_CODE);
            return ApiResponse.success(materialPurchaseFlowPageVO);
        } catch (Exception e) {
            throw new HussarException("表格查询异常");
        }
    }

    @Override
    public ApiResponse<MaterialPurchaseFlowPageVO> hussarQueryPage_order_custom(Page<MaterialPurchaseFlow> page) {
        try {
            Page<MaterialPurchaseFlow> pager = new Page<>(page.getCurrent(), page.getSize());
            Map<String, String[]> parameterMap = new HashMap<>();
            String[] orderParameter = new String[1];
            if (page.orders() != null) {
                for (OrderItem orderItem : page.orders()) {
                    if (orderItem.isAsc()) {
                        orderParameter[0] = orderItem.getColumn() + ",asc;";
                    } else {
                        orderParameter[0] = orderItem.getColumn() + ",desc;";
                    }
                }
            }
            parameterMap.put("orderRule", orderParameter);
            MaterialPurchaseFlowPageVO materialPurchaseFlowPageVO = new MaterialPurchaseFlowPageVO();
            // 查询条件构造器,将排序条件封装成QueryWrapper
            SingleTableQueryGenerator singleTableQueryGenerator = new SingleTableQueryGenerator();
            QueryWrapper<MaterialPurchaseFlow> queryWrapper = singleTableQueryGenerator.initQueryWrapper(new MaterialPurchaseFlow(), parameterMap);
            List<MaterialPurchaseFlow> list = materialPurchaseFlowMapper.hussarQueryPage_order_custom(pager, queryWrapper);
            materialPurchaseFlowPageVO.setData(list);
            materialPurchaseFlowPageVO.setCount(pager.getTotal());
            materialPurchaseFlowPageVO.setCode(RETURN_CODE);
            return ApiResponse.success(materialPurchaseFlowPageVO);
        } catch (Exception e) {
            throw new HussarException("表格查询异常");
        }
    }

    @Override
    public ApiResponse<MaterialPurchaseFlowPageVO> hussarQuerymaterialPurchaseFlowCondition_1Page(MaterialPurchaseFlowMaterialpurchaseflowdataset1 materialpurchaseflowdataset1) {
        try {
            MaterialPurchaseFlowPageVO materialPurchaseFlowPageVO = new MaterialPurchaseFlowPageVO();
            Page<MaterialPurchaseFlow> pager = new Page<>(materialpurchaseflowdataset1.getCurrent(), materialpurchaseflowdataset1.getSize());
            Map<String, String[]> parameterMap = new HashMap<>();
            String[] orderParameter = new String[1];
            if (materialpurchaseflowdataset1.getOrders() != null) {
                for (OrderItem orderItem : materialpurchaseflowdataset1.getOrders()) {
                    if (orderItem.isAsc()) {
                        orderParameter[0] = orderItem.getColumn() + ",asc;";
                    } else {
                        orderParameter[0] = orderItem.getColumn() + ",desc;";
                    }
                }
            }
            parameterMap.put("orderRule", orderParameter);
            materialpurchaseflowdataset1.setMaterialPurchaseFlowapplyUserFullLike(materialpurchaseflowdataset1.getMaterialPurchaseFlowapplyUserFullLike().replaceAll("/", "//").replaceAll("%", "/%").replaceAll("_", "/_").replaceAll("\\[", "/[").replaceAll("]", "/]"));
            // 查询条件构造器,将排序条件封装成QueryWrapper
            SingleTableQueryGenerator singleTableQueryGenerator = new SingleTableQueryGenerator();
            QueryWrapper<MaterialPurchaseFlow> queryWrapper = singleTableQueryGenerator.initQueryWrapper(new MaterialPurchaseFlow(), parameterMap);
            List<MaterialPurchaseFlow> list = materialPurchaseFlowMapper.hussarQuerymaterialPurchaseFlowCondition_1Page(pager, materialpurchaseflowdataset1, queryWrapper);
            materialPurchaseFlowPageVO.setData(list);
            materialPurchaseFlowPageVO.setCount(pager.getTotal());
            materialPurchaseFlowPageVO.setCode(RETURN_CODE);
            return ApiResponse.success(materialPurchaseFlowPageVO);
        } catch (Exception e) {
            throw new HussarException("表格查询异常");
        }
    }

    @Override
    public ApiResponse<MaterialPurchaseFlowPageVO> hussarQuerymaterialPurchaseFlowCondition_1Page_order_custom(MaterialPurchaseFlowMaterialpurchaseflowdataset1 materialpurchaseflowdataset1) {
        try {
            MaterialPurchaseFlowPageVO materialPurchaseFlowPageVO = new MaterialPurchaseFlowPageVO();
            Page<MaterialPurchaseFlow> pager = new Page<>(materialpurchaseflowdataset1.getCurrent(), materialpurchaseflowdataset1.getSize());
            Map<String, String[]> parameterMap = new HashMap<>();
            String[] orderParameter = new String[1];
            if (materialpurchaseflowdataset1.getOrders() != null) {
                for (OrderItem orderItem : materialpurchaseflowdataset1.getOrders()) {
                    if (orderItem.isAsc()) {
                        orderParameter[0] = orderItem.getColumn() + ",asc;";
                    } else {
                        orderParameter[0] = orderItem.getColumn() + ",desc;";
                    }
                }
            }
            parameterMap.put("orderRule", orderParameter);
            materialpurchaseflowdataset1.setMaterialPurchaseFlowapplyUserFullLike(materialpurchaseflowdataset1.getMaterialPurchaseFlowapplyUserFullLike().replaceAll("/", "//").replaceAll("%", "/%").replaceAll("_", "/_").replaceAll("\\[", "/[").replaceAll("]", "/]"));
            // 查询条件构造器,将排序条件封装成QueryWrapper
            SingleTableQueryGenerator singleTableQueryGenerator = new SingleTableQueryGenerator();
            QueryWrapper<MaterialPurchaseFlow> queryWrapper = singleTableQueryGenerator.initQueryWrapper(new MaterialPurchaseFlow(), parameterMap);
            List<MaterialPurchaseFlow> list = materialPurchaseFlowMapper.hussarQuerymaterialPurchaseFlowCondition_1Page_order_custom(pager, materialpurchaseflowdataset1, queryWrapper);
            materialPurchaseFlowPageVO.setData(list);
            materialPurchaseFlowPageVO.setCount(pager.getTotal());
            materialPurchaseFlowPageVO.setCode(RETURN_CODE);
            return ApiResponse.success(materialPurchaseFlowPageVO);
        } catch (Exception e) {
            throw new HussarException("表格查询异常");
        }
    }

    @Override
    @HussarTransactional
    public ApiResponse<String> flowTableDelete(String id) {
        try {
            // 调用操作业务数据的方法
            if (StringUtil.isNotBlank(id)) {
                List<String> idList = Collections.singletonList(id);
                materialPurchaseItemService.remove(Wrappers.<MaterialPurchaseItem>lambdaUpdate().in(MaterialPurchaseItem::getMaterialPurchaseId, idList));
                materialPurchaseFlowMasterService.removeByIds(idList);
            }
            return ((MaterialPurchaseFlowService) AopContext.currentProxy()).deleteProcessInstance(id);
        } catch (Exception e) {
            throw new HussarException(e.getMessage());
        }
    }

    @Override
    @HussarTransactional
    public ApiResponse<String> flowTableDeleteUnStart(String id) {
        // 验证流程状态
        BpmResponseResult validateResult;
        try {
            validateResult = ((MaterialPurchaseFlowService) AopContext.currentProxy()).getValidateResult(id);
            if (BpmConstant.SUCCESS_CODE.equals(validateResult.getCode())) {
                String state = validateResult.getResult().get(0) == null ? "" : validateResult.getResult().get(0).toString();
                switch(state) {
                    // 1 代表流程已经启动，并且节点处于第一节点，可以删除业务数据和流程数据
                    case BpmConstant.SUCCESS_CODE:
                        // 删除业务数据
                        if (StringUtil.isNotBlank(id)) {
                            List<String> idList = Collections.singletonList(id);
                            materialPurchaseItemService.remove(Wrappers.<MaterialPurchaseItem>lambdaUpdate().in(MaterialPurchaseItem::getMaterialPurchaseId, idList));
                            materialPurchaseFlowMasterService.removeByIds(idList);
                        }
                        // 删除流程数据
                        return ((MaterialPurchaseFlowService) AopContext.currentProxy()).deleteProcessInstance(id);
                    // 2 代表流程已经启动，并且节点不处于第一节点，不可以删除业务数据和流程数据
                    case "2":
                        throw new HussarException(validateResult.getMsg());
                    // 0 代表流程没有启动，可以删除业务数据，不需要删除流程数据
                    case "0":
                        // 删除业务数据
                        if (StringUtil.isNotBlank(id)) {
                            List<String> idList = Collections.singletonList(id);
                            materialPurchaseItemService.remove(Wrappers.<MaterialPurchaseItem>lambdaUpdate().in(MaterialPurchaseItem::getMaterialPurchaseId, idList));
                            materialPurchaseFlowMasterService.removeByIds(idList);
                        }
                        return ApiResponse.success("");
                    default:
                        throw new HussarException(TfModelEnum.TF_DELETION_FAILED.getMessage());
                }
            }
            throw new HussarException(TfModelEnum.TF_DELETION_FAILED.getMessage());
        } catch (Exception e) {
            throw new HussarException(e.getMessage());
        }
    }

    @Override
    @HussarTransactional
    @HussarDs("master")
    public BpmResponseResult getValidateResult(String id) {
        return InstanceEngineService.validateDeleteByBusinessKey(String.valueOf(id));
    }

    @Override
    @HussarTransactional
    @HussarDs("master")
    public ApiResponse<String> deleteProcessInstance(String id) {
        BpmResponseResult bpmResponseResult;
        try {
            bpmResponseResult = InstanceEngineService.deleteProcessInstanceByBusinessKey(String.valueOf(id));
            if (BpmConstant.SUCCESS_CODE.equals(bpmResponseResult.getCode())) {
                return ApiResponse.success("");
            }
            throw new HussarException(bpmResponseResult.getMsg());
        } catch (Exception e) {
            throw new HussarException(e.getMessage());
        }
    }

    @Override
    public ApiResponse<MaterialPurchaseFlowPageVO> hussarQuerymaterialPurchaseFlowCondition_1(MaterialPurchaseFlowMaterialpurchaseflowdataset1 materialpurchaseflowdataset1) {
        try {
            MaterialPurchaseFlowPageVO materialPurchaseFlowPageVO = new MaterialPurchaseFlowPageVO();
            materialpurchaseflowdataset1.setMaterialPurchaseFlowapplyUserFullLike(materialpurchaseflowdataset1.getMaterialPurchaseFlowapplyUserFullLike().replaceAll("/", "//").replaceAll("%", "/%").replaceAll("_", "/_").replaceAll("\\[", "/[").replaceAll("]", "/]"));
            List<MaterialPurchaseFlow> list = materialPurchaseFlowMapper.hussarQuerymaterialPurchaseFlowCondition_1(materialpurchaseflowdataset1);
            materialPurchaseFlowPageVO.setData(list);
            if (HussarUtils.isNotEmpty(list)) {
                materialPurchaseFlowPageVO.setCount((long) list.size());
            }
            materialPurchaseFlowPageVO.setCode(RETURN_CODE);
            return ApiResponse.success(materialPurchaseFlowPageVO);
        } catch (Exception e) {
            throw new HussarException("表格查询异常");
        }
    }
}
